<!-- DynamicInput.vue -->
<template>
  <el-input v-model="inputValue" v-bind="inputProps" />
</template>

<script setup lang="ts">
import { computed } from 'vue'

const props = withDefaults(defineProps<{
  modelValue: any;
  config: any;
}>(), {
  modelValue: {},
  config: {},
})
const emit = defineEmits(['update:modelValue', 'updateCfv'])

// 只提取 config.props 里的属性给 el-input
const inputProps = computed(() => props.config.props || {})

const inputValue = computed({
  get() {
    return props.modelValue.value ?? ''
  },
  set(val) {
    emit('update:modelValue', { value: val, label: val })
  },
})
</script>
